Shader "Hidden/BWDiffuse"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _bwBlend("black white", Range(0,1)) = 0
    }
    SubShader
    {
        // No culling or depth
        Cull Off ZWrite Off ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert_img // 使用内置的顶点着色器
            #pragma fragment frag

            #include "UnityCG.cginc"

            uniform sampler2D _MainTex;
            uniform float _bwBlend;

            // 片元着色器
            fixed4 frag(float4 pos : SV_POSITION, float2 uv : TEXCOORD0) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, uv);
                // 亮度值
                float lum = col.r * 0.2126 + col.g * 0.7152 + col.b * 0.0722;
                float4 bw = float4(lum, lum, lum, 1);

                float4 result = lerp(col, bw, _bwBlend);

                return result;
            }
            ENDCG
        }
    }
}